/*
 * @Date: 2020-11-27 15:01:19
 * @LastEditors: 小枫
 * @description: description
 * @LastEditTime: 2020-11-27 17:01:54
 * @FilePath: \stu-nest\src\modules\auth\auth.controller.ts
 */
import { Controller, Get, Post, Request, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiBody, ApiTags } from '@nestjs/swagger';
import { AuthService } from './auth.service';

@ApiTags('auth')
@Controller()
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Post('auth/login')
  @UseGuards(AuthGuard('local'))
  @ApiBody({ description: '输入账号密码' })
  async login(@Request() req) {
    return this.authService.login(req.user);
  }

  @UseGuards(AuthGuard('jwt'))
  @Get('profile')
  getProfile(@Request() req) {
    return req.user;
  }
}
